function confirmMsg(msg){
    $.confirm({
        title: '警告',
        content: msg,
        type: 'orange',
        typeAnimated: false,
        buttons: {
            close: {
                text: '关闭',
            }
        }
    });
}

function refuseMsg(msg) {
    $.confirm({
        title: '对话框',
        content: msg,

        buttons: {
            confirm: {
                text: '确认',
                action: function(){
                    return false
                }
            }
        }
    });
}

function showSuccessMsg(msg,callback) {
    $.confirm({
        title: '成功',
        content: msg,
        type: 'green',
        buttons: {
            omg: {
                text: '谢谢',
                btnClass: 'btn-green',
                action:function () {
                    callback()
                }
            },
        }
    });
}

// 表单ajax事件
function form_ajax(form,url,data,jumpUri){
    let AjaxURL = url;
    $.ajax({
        type: "POST",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        url: AjaxURL,
        data: JSON.stringify(data),
        success: function (result) {
            if(result.code===200){
                showSuccessMsg(result.msg,function () {
                    window.location.href = jumpUri;
                })
                                return
            }else{
                $.confirm({
                    title: '警告',
                    content: result.msg,
                    type: 'orange',
                    typeAnimated: false,
                    buttons: {
                        close: {
                            text: '关闭',
                        }
                    }
                });
            }
        },
        error: function(result) {
            $.confirm({
                title: '警告',
                content: "无法链接服务器！！！！",
                type: 'orange',
                typeAnimated: false,
                buttons: {
                    close: {
                        text: '关闭',
                    }
                }
            });
        }

    });
}

// postajax事件
function post_ajax(url,data,jumpUri) {
    $.ajax({
        type: "POST",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        url: url,
        data: JSON.stringify(data),
        success: function (result) {
            if (result.code === 200) {
                showSuccessMsg(result.msg, function () {
                    console.log(result.msg)
                    window.location.href = jumpUri;
                })
                return
            } else {
                $.confirm({
                    title: '警告',
                    content: result.msg,
                    type: 'orange',
                    typeAnimated: false,
                    buttons: {
                        close: {
                            text: '关闭',
                        }
                    }
                });

            }
        },
        error: function (result) {
            $.confirm({
                title: '警告',
                content: '无法链接服务器啊',
                type: 'orange',
                typeAnimated: false,
                buttons: {
                    close: {
                        text: '关闭',
                    }
                }
            });
        }

    });
}

    // postajax事件
    function post_ajax(url,data,jumpUri) {
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            url: url,
            data: JSON.stringify(data),
            success: function (result) {
                if (result.code === 200) {
                    showSuccessMsg(result.msg, function () {
                        console.log(result.msg)
                        window.location.href = jumpUri;
                    })
                    return
                } else {
                    $.confirm({
                        title: '警告',
                        content: result.msg,
                        type: 'orange',
                        typeAnimated: false,
                        buttons: {
                            close: {
                                text: '关闭',
                            }
                        }
                    });
                }
            },
            error: function (result) {
                $.confirm({
                    title: '警告',
                    content: '无法链接服务器啊',
                    type: 'orange',
                    typeAnimated: false,
                    buttons: {
                        close: {
                            text: '关闭',
                        }
                    }
                });
            }

        });
}


// GETajax事件
function get_ajax(url,data,jumpUri) {
    $.ajax({
        type: "GET",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        url: url,
        data: JSON.stringify(data),
        success: function (result) {
            if (result.code === 200) {
                showSuccessMsg(result.msg, function () {
                    console.log(result.msg)
                    window.location.href = jumpUri;
                })
                return
            } else {
                $.confirm({
                    title: '警告',
                    content: result.msg,
                    type: 'orange',
                    typeAnimated: false,
                    buttons: {
                        close: {
                            text: '关闭',
                        }
                    }
                });
            }
        },
        error: function (result) {
            $.confirm({
                title: '警告',
                content: '无法链接服务器啊',
                type: 'orange',
                typeAnimated: false,
                buttons: {
                    close: {
                        text: '关闭',
                    }
                }
            });
        }

    });
}